#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void printArray(int* a,int n)
{
	for (int i = 0; i < n; i++)
	{
		printf("%d ", a[i]);
	}
	printf("\n");
}
void shellSort(int* a,int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;
		for (int i = 0; i < n - gap; i++)
		{
			int end = i;
			int x = a[end + gap];
			while (end >= 0)
			{
				if (x < a[end])
				{
					a[end + gap] = a[end];
					end -= gap;
				}
				else
					break;
			}
			a[end + gap] = x;
		}
	}
}
int main()
{
	int a[] = { 2,5,6,1,4,9,7,3,8,10 };
	printArray(a, sizeof(a) / sizeof(a[0]));
	shellSort(a, sizeof(a) / sizeof(a[0]));
	printArray(a,sizeof(a)/sizeof(a[0]));
	return 0;
}